unit ULacamentoTitulo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls, DB;

type
  TFLacamentoTitulo = class(TForm)
    DBGItens: TDBGrid;
    Panel1: TPanel;
    BtnFechar: TBitBtn;
    dsLancamentos: TDataSource;
    Label1: TLabel;
    lbOrigem: TLabel;
    Label2: TLabel;
    lbTitulo: TLabel;
    Panel2: TPanel;
    Label3: TLabel;
    lbTotal: TLabel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BtnFecharClick(Sender: TObject);
    procedure DBGItensDblClick(Sender: TObject);
    procedure DBGItensDrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FLacamentoTitulo: TFLacamentoTitulo;

implementation

uses ContasPagar, ContasReceber, Lancamento;

{$R *.dfm}

procedure TFLacamentoTitulo.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  FLacamentoTitulo.Release;
  FLacamentoTitulo := nil;
end;

procedure TFLacamentoTitulo.BtnFecharClick(Sender: TObject);
begin
  Close;
end;

procedure TFLacamentoTitulo.DBGItensDblClick(Sender: TObject);
begin
  if FLancamento = nil then
    Application.CreateForm(TFLancamento, FLancamento);

  if FLancamento.cdsCadastro.State = dsBrowse then
  begin

    if  FLancamento.cdsCadastro.Locate('LANC_CODIGO', dsLancamentos.DataSet.FieldByName('LANCAMENTO').AsInteger, []) then
    begin
      Self.Close;
      FLancamento.PegaTitulo(True);
      FLancamento.Show;
    end;

  end;
end;

procedure TFLacamentoTitulo.DBGItensDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  {

  if dsLancamentos.DataSet.FieldByName('EXCLUIDO').AsString = 'S' then
    DBGItens.Canvas.Font.Color := clRed
  else if dsLancamentos.DataSet.FieldByName('EXCLUIDO').AsString = 'R' then
    DBGItens.Canvas.Font.Color := clBlue
  else }
    DBGItens.Canvas.Font.Color := clBlack;
    DBGItens.Canvas.Brush.Color:= clwhite;

  DBGItens.DefaultDrawDataCell( Rect, Column.Field, State);
end;

end.
